
$(function() {
    $("#comment-form").dialog({
        autoOpen: false,
        height: 500,
        width: 800,
        modal: true,
        buttons: {
            "送出": function() {

            	$.ajax({
                    url: "ILS_comment.ils?ils=insert_coment",
                    async: false,
                    data:getCommentData(),
                    type: 'post',
                    success: function(res) {
                    	if("success" == res){
                            alert("成功！");
                            $("#comment-form").dialog("close");
                    	}else{
                    		alert("失敗!");
                    	}
                    },
                    error: function(data) {
                        alert("連線失敗！");
                    }
                });
            },
            "取消": function() {
                $(this).dialog("close");
            }
        },
        close: function() {
            allFields.val("").removeClass("ui-state-error");
        }
    });
    
    $("#openComment").click(function() {
    	$("#comment-form").dialog("open");
    });
});

//得到目前所有資料
function getCommentData(){
    var dataObject = {
        "comment" : $("#comment").val()
    };
    
    return dataObject;
}